#include "CValidatorFactory.h"
#include "CITLValidatorImpl.h"
#include "CMEIValidatorImpl.h"
#include "CCoinMechImpl.h"

using namespace zl;

static IValidatorInterface* g_VALIDATOR = nullptr;

IValidatorInterface* CValidatorFactory::getValidator(int32_t type)
{
    switch (type)
    {
#ifdef Q_OS_WIN
    case IValidatorInterface::EValidatorType_ITL:
    {
        if (g_VALIDATOR == nullptr)
        {
            g_VALIDATOR = new CITLValidatorImpl;
        }
        return g_VALIDATOR;
    }
#endif // Q_OS_WIN
    case IValidatorInterface::EValidatorType_MEI:
    {
        if (g_VALIDATOR == nullptr)
        {
            g_VALIDATOR = new CMEIValidatorImpl;
        }
        return g_VALIDATOR;
    }
    case IValidatorInterface::EValidatorType_YD_M175:
    {
        if (g_VALIDATOR == nullptr)
        {
            g_VALIDATOR = new CCoinMechImpl;
        }

        return g_VALIDATOR;
    }
    default:
        return nullptr;
    }
}
